import { login } from './api.js';
import $store from '@/store/index.js';

/**
 * 测试用 固定账号密码登录
 */
export function phoneLogin(){
	const data = {
		username: '15365045842',
		password: '123456'
	};
	login(data).then((res) => {
		$store.commit('setUser', res.userInfo);
	});
}

export function isLogin(redirect = false){
	const login = !$store.state.$token ? false : true;
	if(redirect && !login) uni.redirectTo({
		url: '@/pages/home/login'
	});
	return login;
}